/**
 * @file ${relativeFile}
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @brief
 * @see https://doi.org/10.1137/0206024
 * @see https://www.luogu.com.cn/record/75397780
 * @version 1.0
 * @date 2022-05-08
 *
 * @copyright Copyright (c) 2022
 *
 **/
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int kmpNext[N];
char text[N], pattern[N];
int textLen, patternLen;
int main() {
  cin >> text + 1 >> pattern + 1;  // 从下标 1 开始
  textLen = strlen(text + 1), patternLen = strlen(pattern + 1);
  for (int i = 2, j = 0; i <= patternLen; ++i) {
    while (j && pattern[i] != pattern[j + 1]) j = kmpNext[j];
    if (pattern[i] == pattern[j + 1]) j++;
    kmpNext[i] = j;
  }
  for (int i = 1, j = 0; i <= textLen; ++i) {
    while (j && text[i] != pattern[j + 1]) j = kmpNext[j];
    if (text[i] == pattern[j + 1]) j++;
    if (j == patternLen) {
      cout << i - patternLen + 1 << endl;  // 输出模式串在原串中的起点
    }
  }

  // 第二个问题就是 next 数组
  for (int i = 1; i <= patternLen; ++i) {
    cout << kmpNext[i] << ' ';
  }
  cout << endl;
}
